/*
 * Copyright (c) 2010 Philip Foulkes <philip.foulkes@gmail.com>
 *
 * This file is free software and is made available under the 
 * terms of the GNU General Public License, version 2, or at your
 * option, any later version
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 */

#ifndef MRP_ITERATOR_H_
#define MRP_ITERATOR_H_

struct mrp_iterator;

typedef void * (*mrp_iterator_get_internal)(struct mrp_iterator * mrp_iterator, void * my_object); 
typedef void (*mrp_iterator_next_internal) (struct mrp_iterator * mrp_iterator, void * my_object); 
typedef int (*mrp_iterator_at_end_internal)(struct mrp_iterator * mrp_iterator, void * my_object); 

struct mrp_iterator_ops
{
	mrp_iterator_get_internal 		mrp_iterator_get_internal;
	mrp_iterator_next_internal 		mrp_iterator_next_internal;
	mrp_iterator_at_end_internal 	mrp_iterator_at_end_internal;
};

struct mrp_iterator
{
	struct mrp_iterator_ops * mrp_iterator_ops;
	void * my_object;
};

struct mrp_iterator * mrp_iterator_create_and_init (void * my_object, struct mrp_iterator_ops * mrp_iterator_ops);
int mrp_iterator_init (struct mrp_iterator * mrp_iterator, void * my_object, struct mrp_iterator_ops * mrp_iterator_ops);

void mrp_iterator_destroy (struct mrp_iterator ** mrp_iterator);
void mrp_iterator_cleanup (struct mrp_iterator * mrp_iterator);

void * mrp_iterator_get (struct mrp_iterator * mrp_iterator); 
void mrp_iterator_next  (struct mrp_iterator * mrp_iterator); 
int mrp_iterator_at_end (struct mrp_iterator * mrp_iterator); 

#endif
